<?php 

function trunc($phrase, $max_words) {

   $phrase_array = explode(' ',$phrase);

   if(count($phrase_array) > $max_words && $max_words > 0)

      $phrase = implode(' ',array_slice($phrase_array, 0, $max_words)).'...';

   return $phrase;

}

?>

<div class="content_pink text-center">

    <div class="cover">

        <div class="cover_images">

            <img src="images/cover-sp.png"/>

        </div>

        <div class="cover_flower">

            <img src="images/cover_flower.png"/>

        </div>

    </div><!--cover-->

    <div class="box_contact">

        <div class="content_contact">

            <div class="icon_flower1">

                <img src="images/icon_flower1.png"/>

            </div>

            <div class="icon_flower2">

                <img src="images/icon_flower2.png"/>

            </div>

            <div class="contact">

                <h1>Liên hệ</h1>

                <span>+84(4)6273-1346</span>

                <span>080-4135-6092</span>

            </div>

        </div>

    </div><!--lien he-->

</div><!--content-->

<div class="sp-list-product text-center kienthuc-con">

    <div class="sp-border">

        <div class="list-danhmuc">

            <div class="icon_flower4">

                <img src="images/icon_flower_sp_hot.png"/>

            </div>

            <div class="content-danhmuc">

                <h1>KIẾN THỨC</h1>

                <ul>

                    <?php foreach($category as $cat) { ?>

                    <li><?php

                    echo $this->Html->link(

                            trunc($cat['NewsCategory']['name'],5), array('controller' => 'News', 'action' => 'category', $cat['NewsCategory']['alias'])

                    );

                    ?></li>

                    <?php } ?>

                </ul>

            </div>

            <div class="content-danhmuc hot-news">

                <h1>BÀI NỔI BẬT</h1>

                <ul>

                    <?php foreach($other_news as $n) { ?> <li> <?php echo $this->Html->link(

                            trunc($n['News']['name'],5), array('controller' => 'News', 'action' => 'detail', $n['News']['alias']), array('escape' => false, 'title' => $n['News']['name'])

                    );

                    ?></li> <?php } ?>

                </ul>

            </div>

        </div>

        <div class="product-main content-kienthuc">

            <?php foreach($list_news as $n) { ?>

            <div class="news-list">

                <?php

                    echo $this->Html->link(

                            $this->Html->image($n['News']['images'], array('style' => 'width: 117px; height: 117px;', 'alt' => $n['News']['name'])), array('controller' => 'News', 'action' => 'detail', $n['News']['alias']), array('escape' => false, 'title' => $n['News']['name'])

                    );

                    ?>

                <div class="kienthuc-nd">

                    <h1> <?php echo $this->Html->link(

                            $n['News']['name'], array('controller' => 'News', 'action' => 'detail', $n['News']['alias']), array('escape' => false, 'title' => $n['News']['name'])

                    );

                    ?></h1>

                    <span>

                        <?php echo $n['News']['description'] ?>

                    </span>

                </div>

            </div>

            <?php } ?>

            <div class="page-product">

                <ul class="list-inline">

                <?php

                    if ($this->Paginator->counter('{:pages}') > 1) {

                        echo $this->Paginator->numbers(array( 'separator' => '', 'tag' => 'li', 'currentLink' => true, 'currentClass' => 'active', 'currentTag' => 'a'));

                    }

                    ?>

                </ul>

            </div>



        </div>

    </div>

</div>